﻿using OnlineStore.Model;
using System;
using System.Threading.Tasks;


namespace OnlineStore.ViewModel
{
    public class LogViewModel : NotifyBase
    {
        public LogViewModel()
        {
            this.CleanLogCommand = new CommandBase();
            this.CleanLogCommand.ExcuteAction = new Action<object>(this.CleanLog);
            this.CleanLogCommand.CanExecuteFunc = new Func<object, bool>((o) => { return true; });
            SetInit();
        }

        private void SetInit()
        {
            MyLogModel = new LogModel();
        }

        /// <summary>
        /// 获取或设置 LogModel 对象
        /// </summary>
        public LogModel MyLogModel { get; set; }

        /// <summary>
        /// 获取或设置详细日志窗口日志内容
        /// </summary>
        //public string DetailedInfo
        //{
        //    get { return MyLogModel.DetailedInfo; }
        //    set { MyLogModel.DetailedInfo = value; }
        //}

        /// <summary>
        /// 清除详细日志内容事件
        /// </summary>
        public CommandBase CleanLogCommand { get; set; }
        private async void CleanLog(object parameter)
        {
            await Task.Run(() =>
            {
                MyLogModel.CleanInfo();
            });
        }
    }
}
